package com.hst.capacity.domain.model.response.fleet;

import com.hst.capacity.domain.model.entity.driver.DriverEntity;
import com.hst.capacity.domain.model.entity.driver.DriverProfileEntity;
import com.hst.capacity.domain.model.entity.vehicle.VehicleEntity;
import com.hst.capacity.domain.model.entity.vehicle.VehicleLicenseEntity;
import com.hst.capacity.domain.model.entity.vehicle.VehicleProfileEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;

import java.time.LocalDateTime;
import java.util.List;

@Data
@NoArgsConstructor
@Alias("FleetSearchDriverVO")
public class FleetSearchDriverVO {

    private String idDriver;
    private String idFranchisee;
    private String idAgent;
    private String idFleet;
    private String driverName;
    private String driverCode;
    private String driverMobile;
    private LocalDateTime createTime;
    private String idVehicle;
    private String plateNumber;
    private String licenseNo;
    private Integer vehicleServiceType = 2;

    public FleetSearchDriverVO (DriverEntity driverEntity, DriverProfileEntity driverProfileEntity,
                               VehicleEntity vehicleEntity, VehicleLicenseEntity vlEntity) {
        this.idDriver=driverEntity.getIdDriver();
        this.idFranchisee=driverEntity.getIdFranchisee();
        this.idAgent=driverEntity.getIdAgent();
        this.idFleet=driverEntity.getIdFleet();
        this.driverCode=driverEntity.getDriverCode();
        this.driverMobile=driverEntity.getDriverMobile();
        this.createTime=driverEntity.getCreateTime();
        if (vehicleEntity!=null){
            this.idVehicle=vehicleEntity.getIdVehicle();
            this.plateNumber=vehicleEntity.getPlateNumber();
        }
        if (driverProfileEntity != null){
            this.driverName=driverProfileEntity.getRealName();
        }
        if (vlEntity != null) {
            this.licenseNo = vlEntity.getLicenseNo();
            if (vlEntity.getServiceType() != null)
                this.vehicleServiceType = vlEntity.getServiceType();
        }
    }

    public FleetSearchDriverVO(DriverEntity d, VehicleEntity v){
        this.idDriver=d.getIdDriver();
        this.driverCode=d.getDriverCode();
        this.driverMobile=d.getDriverMobile();
        this.createTime=d.getCreateTime();
        this.idVehicle=v.getIdVehicle();
        this.plateNumber=v.getPlateNumber();
    }

    public FleetSearchDriverVO(DriverEntity d){
        this.idDriver=d.getIdDriver();
        this.driverCode=d.getDriverCode();
        this.driverMobile=d.getDriverMobile();
        this.createTime=d.getCreateTime();
    }

}
